Virtual machines (VMs) in a collection may need to be placed on hosts. For example, placement may occur when a request to power on virtual machines in the collection is received. A placement engine may determine host assignments based on a set of constraints. For example, using a fault-tolerance (FT) policy, a placement engine needs to place a primary virtual machine and one or more secondary virtual machines on different hosts. The hosts on which the primary virtual machine and the secondary virtual machines are placed should be similar hosts where the hosts are not only compatible with all the virtual machines in the collection but also share a common set of attributes.
For example, in fault-tolerance, a primary virtual machine is placed on a first host. To provide fault-tolerance, a secondary virtual machine is placed on a different host (e.g., a second host). Further, if other secondary virtual machines exist, the other secondary virtual machines are each placed on a separate host different from the first host and the second host. Thus, if a first host fails, then one of the hosts that includes a secondary virtual machine may be used.
The Virtual machines in the collection should be placed on similar hosts with a common set of attributes. For example, the virtual machines in the collection may be using a cluster of pooled resources. The cluster may include hosts that include different attributes. For example, a cluster may have four hosts, two hosts with a first type of computer processor and two hosts with a second type of computer processor. If a primary virtual machine and secondary virtual machine are to be placed, a constraint may be that the primary virtual machine and secondary virtual machine be placed on either the first type of computer processors or the second type of computer processors. That is, it is invalid to place the primary virtual machine on a host including the first type of processor and then place the secondary virtual machine on a host including the second type of computer processor.
In one example, a placement engine may select a host for the primary virtual machine. After placing the first virtual machine, the placement engine does not know which hosts in the cluster would appropriate for placing the secondary VM to meet the constraints. Thus, the placement engine might select an incompatible host for the secondary virtual machine. If this occurs, then a second placement attempt may be performed. For example, the placement engine may select another host for the secondary virtual machine. This process continues until the placement engine selects a host that satisfies the constraints. For example, if the primary virtual machine is placed on a first host with the first type of computer processor, the placement engine places the secondary virtual machine on hosts until a second host with the first type of computer processor is selected. This may result in multiple placement attempts, which is inefficient, distracts from a goal of a user who wants the virtual machines placed, and may produce misleading error messaging.
Another solution may place the primary virtual machine on a first host. Then, a set of hosts that is similar to the first host is determined. A secondary virtual machine can be placed on one of the determined set of hosts. This, however, requires that the placement engine place the primary virtual machine on the first host before determining the set of hosts. Thus, if the placement of the primary virtual machine is on a host that belongs to a non-optimal set of hosts, the placement may not be ideal. For example, a second set of hosts may have more resources available, but the virtual machines in the collection are not placed on those hosts because the primary virtual machine was first placed on a host associated with a different set of hosts, and thus some or all of the secondary virtual machines may not be placed.